z<template>
	<view class="contents" :style="'height:'+screenHeight+'px;'">
		<view class="bodys">
			<view class="none" v-if="show">
				<view class="coent">
					<u-empty text="您已提交过满意度评价" mode="list" icon-size="200">
					</u-empty>
				</view>
			</view>
			<view class="conent" v-else>
				<view class="header">
					<view style="text-align: center;">集宁区妇幼保健计划生育服务中心</view>
					<view style="text-align: center;">职工满意度调查</view>
				</view>
				<!-- <view class="" style="padding: 10rpx;">
					<span>&emsp;亲爱的同仁！感谢您参与此次满意度调查，您的意见将对其所从事的工作的总体态度，请认真填写。</span>
					<span>&emsp;请在提供的分值对应栏中打√，10分非常满意，8分满意，6分一般，0不满意。</span>
				</view> -->
				<view class="jianyi">
					
					
					
					<u-field v-model="name" required label="姓名" placeholder="请填写姓名"
						>
					</u-field>
					<text v-if="!name" class="error-tip">
						请填写姓名！
					</text>
					<u-field v-model="keshi" required label="所在科室" placeholder="请填写所在科室"
						>
					</u-field>
					<text v-if="!keshi" class="error-tip">
						请填写所在科室！
					</text>
					<!-- <u-field v-model="xingbie" required label="性别" placeholder="请填写性别"  :error-message="xingbie == '' ? '请填写性别！' : ''">
					</u-field> -->
					<!-- s -->
					
					
					<u-form-item required label="性别" label-width="140" style="padding-left: 4%;"  >
						<u-input v-model="xingbie" placeholder="请选择性别" type="select" @click="select1.show=true"  placeholderStyle="color:gray"/>
					</u-form-item>
					<text v-if="!xingbie" class="error-tip">
						请选择性别!
					</text>
					
					
					<u-field v-model="zaigang" required label-width="180" type="number" label="在岗年限(年)"
						placeholder="请填写在岗年限" >
					</u-field>
					<text v-if="!zaigang" class="error-tip">
						请填写在岗年限!
					</text>
					<!-- <u-field v-model="name" label="姓名" placeholder="请填写调查员">
					</u-field> -->
					<!-- <u-field v-model="occupation" label="签字" placeholder="请签字">
					</u-field>
					<u-field v-model="phone" label="调查日期" placeholder="请填写调查日期">
					</u-field> -->

				</view>
				<view class="neiorng">
					<!-- 	<view class="">
						一、个人基本信息
					</view> -->
					<view class="datalist" v-for="(item,index) in datalist2" :key="index">
						<view class="list">
							<span style="color: red;">*&nbsp;</span>
							<!-- <span style="font-weight: bold;">{{item.ProTempCode}}.&nbsp;</span> -->
							<span style="margin-left: 3%;">{{item.ProTemContent}}</span>
						</view>

						<view class="listb">
							<u-radio-group v-model="item.value" iconPlacement="left">
								<u-radio v-for="(itema, indexa) in item.lists" @change="radioGroupChange2"
									label-size="13px" :key="indexa" :name="itema.name">
									{{itema.name}}
								</u-radio>
							</u-radio-group>
						</view>
						<text v-if="!item.value" class="error-tip">
							请选择{{item.ProTem}}!
						</text>
					</view>
				</view>


				<view class="neiorng">
					<view class="">
						二、问卷内容
					</view>
					<view class="datalist" v-for="(item,index) in datalist" :key="index">
						<view class="list">
							<span style="color: red;">*&nbsp;</span>
							<span style="font-weight: bold;">{{item.ProTempCode}}.&nbsp;</span>
							<span>{{item.ProTemContent}}</span>
						</view>
						<!-- @tap="ssss(index)" -->
						<view class="listb">
							<u-radio-group v-model="wjtx[index].value">
								<u-radio v-for="(itema, indexa) in wjtx[index].lists" @change="radioGroupChange"
									:key="indexa" :name="itema.name">
									{{itema.name}}
								</u-radio>
							</u-radio-group>
						</view>
					</view>
					<view class="jianyi">
						<view style="margin-bottom: 10rpx;">您认为医院目前有哪些需要改进的地方，请填写您的意见或建议：</view>
						<u-input v-model="jianyival" border type="textarea" />
					</view>


					<view style="width: 100%;display: flex;justify-content: center;padding:40rpx;">
						<view class="submit">
							<u-button type="primary" @click="submit">提交</u-button>
						</view>
					</view>
				</view>

			</view>

		</view>
		<u-select v-model="select1.show" :list="select1.list" @confirm="onSelect1"></u-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				keshi: '',
				xingbie: '',
				zaigang: '',
				occupation: '',
				phone: '',
				show: true,
				jianyival: '',
				screenHeight: getApp().globalData.screenHeight - 44,
				datalist: '',
				wjtx: [],
				select1: {
					show: false,
					current: {},
					list: [{
							value: 1,
							label: '男'
						},
						{
							value: 2,
							label: '女'
						}
					],
				},
				datalist2: [{
						// ProTempCode: 1,
						ProTem: "在岗类型",
						ProTemContent: "在岗类型",
						lists: [{
								name: '医生',
								//	disabled: false,
							},
							{
								name: '护士',
								//	disabled: false,
							},
							{
								name: '医技人员',
								//	disabled: false,
							},
							{
								name: '行政人员',
								//	disabled: false,
							},

						],
						value: ""

					},

				],
				text: ''
			}
		},
		onLoad() {
			this.list()
		},
		methods: {
			ssss(index) {
				console.log("满意度问题", index)
				if (this.text != '') {
					this.wjtx[index].value = this.text
				}
				console.log("wjtx", this.wjtx)
			},
			pinkProDetails() {
				console.log(this.wjtx)
				console.log(this.datalist)
				let temp3 = {
					prodetail: ''

				}
				let temp = []

				// let temp = `{"prodetail":[`
				for (let i = 0; i < this.wjtx.length; i++) {

					let le
					switch (this.wjtx[i].value) {
						case '非常满意':
							le = 10;
							break
						case '满意':
							le = 8;
							break
						case '一般':
							le = 6;
							break
						case '不满意':
							le = 0;
							break
					}

					temp.push({
						ProTempId: this.datalist[i].ProTempId,
						PF: le
					});





				}
				console.log(temp)
				temp3.prodetail = temp
				// temp = temp + `]}`

				return JSON.stringify(temp3)

			},
			onSelect1(arr) {
				let current = arr[0];
				console.log("current", current)
				let label = current.label;
				this.select1.current = current;
				this.xingbie = label;
				
			},
			submit() {


				if (this.name == '') {
					uni.showToast({
						title: "请输入姓名！",
						icon: 'none',
						duration: 2000
					});
					return


				} else if (this.keshi == '') {
					uni.showToast({
						title: "请输入所在科室！",
						icon: 'none',
						duration: 2000
					});
					return

				} else if (this.xingbie == '') {
					uni.showToast({
						title: "请输入性别！",
						icon: 'none',
						duration: 2000
					});
					return
				} else if (this.zaigang == '') {
					uni.showToast({
						title: "请输入在岗年限！",
						icon: 'none',
						duration: 2000
					});
					return

				} else if (this.datalist2[0].value == '') {
					uni.showToast({
						title: "请选择在岗类型！",
						icon: 'none',
						duration: 2000
					});
					return

				}


				uni.showLoading({
					title: '请稍后',
					mask: true
				});
				let sum = 0
				let item = this.wjtx
				console.log(this.wjtx)
				for (let i = 0; i < item.length; i++) {
					if (item[i].value == '非常满意') {
						sum += 10
					} else if (item[i].value == '满意') {
						sum += 8
					} else if (item[i].value == '一般') {
						sum += 6
					} else {
						sum += 0
					}
				}

			
				let ProDetails = this.pinkProDetails();
				// console.log(this.jianyival,ProDetails,sum,this.name,this.keshi,this.xingbie,this.zaigang,this.datalist2[0].value)
				// console.log("总分", sum)
				// return
				this.$request("ProblemTem", "Submit", {
					SmType: "",
					Content: this.jianyival,
					ProDetails: ProDetails,
					ZPF: sum,
					Name: this.name,
					Dpt: this.keshi,
					Sex: this.xingbie,
					Nl: this.zaigang,
					Phone: "",
					Work: this.datalist2[0].value,
					Protype: 3,


				}).then(res => {
					console.log("提交满意度问题", res)
					if (res.code == 1) {
						this.show = true
						uni.hideLoading();

					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(err => {
					uni.hideLoading();
					console.log("err", err)
					uni.showToast({
						title: err,
						icon: 'none',
						duration: 1000
					});
				});
			},
			radioChange(e) {
				console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				console.log(66666666666666666666);
				console.log(e);
				this.text = e
				console.log("wsat", this.wjtx)

			},
			radioGroupChange2(e) {
				// console.log(66666666666666666666);
				console.log(e);
				this.text = e
				console.log("wsat", this.datalist2)

			},
			list() {
				uni.showLoading({
					title: '请稍后',
					mask: true
				});
				this.$request("ProblemTem", "list", {
					protype: 3


				}).then(res => {
					// console.log("满意度问题", res)
					if (res.code == 1) {
						this.datalist = res.data
						this.wjtx = []
						let objet = {
							lists: [{
									name: '非常满意',
									value: 10
								},
								{
									name: '满意',
									value: 8
								},
								{
									name: '一般',
									value: 6
								}, {
									name: '不满意',
									value: 0
								},
							],
							value: '非常满意'
						}
						for (let i = 0; i < res.data.length; i++) {
							this.wjtx[i] = JSON.parse(JSON.stringify(objet))
						}
						console.log("this.wjtx", this.wjtx)
						console.log("this.datalist", this.datalist)
						this.show = false
						uni.hideLoading();

					} else {
						this.show = true
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(err => {
					this.show = true
					uni.hideLoading();
					console.log("err", err)
					uni.showToast({
						title: err,
						icon: 'none',
						duration: 1000
					});
				});
			}
		}
	}
</script>

<style>
	@import './zhigongmanyidu.css';
</style>